package com.midian.model.common;

import java.io.Serializable;
import java.util.Date;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.MappedSuperclass;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Transient;

import org.hibernate.annotations.GenericGenerator;

import com.midian.common.system.SysStatic;

/**
 * 
 * @Title:父类model  
 * @Desription:所有模型类的父类，包含了如标识，创建时间等信息
 * @Company:MDKG
 * @ClassName:BaseModel.java
 * @Author:Mengfh
 * @CreateDate:2013-6-7 下午5:27:24  
 * @UpdateUser:Mengfh
 * @Version:0.1
 */
@MappedSuperclass
@Inheritance(strategy=InheritanceType.TABLE_PER_CLASS)
/*@Cache(usage=CacheConcurrencyStrategy.READ_WRITE)*/
public class BaseModel extends Model implements Serializable{
	
	private static final long serialVersionUID = 7468140310444243623L;
	
	/** 模型编号 */
	//@GenericGenerator(name = "identity", strategy = "identity")
	//@GeneratedValue(generator = "identity")
	@Id
	@GenericGenerator(name = "uuid", strategy = "uuid")
	@GeneratedValue(generator = "uuid")
	@Column(length = 32)
	private String id;
	/** 创建时间 */
	@Temporal(TemporalType.TIMESTAMP)
	@Column(nullable = false, updatable = false, name = "CREATETIME")
	private Date createTime = new Date();
	/**删除标识*/
	@Column(nullable = false, updatable = false, name = "DELETEFLAG")
	private Integer delFlag = SysStatic.NORMALDELFLAG;
	
	@Transient
	private List idList;
	/**创建时间的开始时间*/
	@Transient
	private Date createTimeMin;
	/**创建时间的结束时间*/
	@Transient
	private Date createTimeMax;

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public List getIdList() {
		return idList;
	}

	public void setIdList(List idList) {
		this.idList = idList;
	}

	public Date getCreateTime() {
		return createTime;
	}

	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}

	public Date getCreateTimeMin() {
		return createTimeMin;
	}

	public void setCreateTimeMin(Date createTimeMin) {
		this.createTimeMin = createTimeMin;
	}

	public Date getCreateTimeMax() {
		return createTimeMax;
	}

	public void setCreateTimeMax(Date createTimeMax) {
		this.createTimeMax = createTimeMax;
	}

	public String showMessage() {
		return this.getClass().getName();
	}

	public Integer getDelFlag() {
		return delFlag;
	}

	public void setDelFlag(Integer delFlag) {
		this.delFlag = delFlag;
	}
	
	/**
	 * 删除标识描述
	 * @return
	 */
	public String getDelFlagDesc() {
		String delFlagDesc = "";
		if(SysStatic.NORMALDELFLAG.equals(this.delFlag)) {
			delFlagDesc = "正常";
		} else {
			delFlagDesc = "禁用";
		}
		return delFlagDesc;
	}
}
